//
//  StoreHelper.m
//  WoWeibo
//
//  Created by Jaedong n.Die_ on 12-5-30.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "StoreHelper.h"

@interface StoreHelper (Private)

@end

@implementation StoreHelper

@synthesize documentPath = _documentPath;

- (id)init {

    self = [super init];
    if(self) {
    
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        _documentPath = [[paths objectAtIndex:0] retain];
    }
    
    return self;
}

- (BOOL)writeFile:(NSString *)filePath withFileData:(NSData *)data {
    
    return [data writeToFile:filePath atomically:YES];
}

- (NSData *)readFile:(NSString *)filePath {
    
    return [[NSFileManager defaultManager] contentsAtPath:filePath];
}

- (BOOL)deleteFile:(NSString *)filePath {

    return [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
}

- (BOOL)createDirectory:(NSString *)directoryPath {

    return [[NSFileManager defaultManager] createDirectoryAtPath:directoryPath withIntermediateDirectories:YES attributes:nil error:nil];
}

- (BOOL)deleteDirectory:(NSString *)directoryPath {

    return [[NSFileManager defaultManager] removeItemAtPath:directoryPath error:nil];
}

- (BOOL)checkFileOrDirectoryIsExists:(NSString *)path {

    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}

- (void)dealloc {

    [_documentPath release];
    
    _documentPath = nil;
    
    [super dealloc];
}

@end
